{block name="title"}地址管理{/block}
{extend name="public/store_menu"}
{block name="content"}
<div style="margin-bottom: 15%;">
    <img src="/img/line.png" style="width: 100%">
    {volist name="address_list" id="vo"}

        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" >
                <div class="mui-media-body">
                    <p class="mui-ellipsis" style="color: black">收货人：{$vo.real_name}</p>
                    <p class="mui-ellipsis" style="color: black">收货地址：{$vo.province_name}  {$vo.city_name}  {$vo.district_name}  {$vo.detail}</p>
                </div>

            </li>
            <li class="mui-media" style="margin-bottom: 0.2rem;height: 50px">
                <div class="mui-input-row mui-radio mui-left" style="font-size: 14px;">
                    <label>设为默认地址</label>
                    <input name="radio1" type="radio" onchange="up_default({$vo.id})"  {$vo.is_default == 1 ? 'checked' : ''} >
                </div>
                <div class="mui-button-row" style="text-align: right;margin-right: 10;margin-top: -35px;margin-left: 0.2;position: unset;">
                    <button class="mui-btn mui-btn-outlined" type="button" onclick="del_address({$vo.id})" >删除</button>&nbsp;&nbsp;
                    <a href="{:Url('user/add_address')}?id={$vo.id}"><button class="mui-btn mui-btn-outlined" type="button" >编辑</button></a>
                </div>
            </li>
        </ul>
    {/volist}
</div>
<nav class="mui-bar mui-bar-tab" style="background-color: red">
    <a class="mui-tab-item mui-active"  href="{:Url('user/add_address')}">
        <span class="mui-tab-label" style="color: white">新增地址</span>
    </a>
</nav>

<script type="text/javascript">
    function up_default($id) {
        mui.ajax('up_address_default',{
            data:{
                id:$id,
            },
            dataType:'json',//服务器返回json格式数据
            type:'post',//HTTP请求类型
            headers:{'Content-Type':'application/json'},
            success:function(data){
                if (data.code==400){
                    mui.alert(data.msg);
                }else {
                    mui.toast(data.msg)
                }
            },
        });
    }
    function del_address($id) {
        mui.ajax('del_address',{
            data:{
                id:$id,
            },
            dataType:'json',//服务器返回json格式数据
            type:'post',//HTTP请求类型
            headers:{'Content-Type':'application/json'},
            success:function(data){
                if (data.code==400){
                    mui.alert(data.msg);
                }else {
                    //mui.toast(data.msg);
                     mui.openWindow({
                        url: data.data,
                    });
                }
            },
        });
    }
//    function add_address() {
//        mui.openWindow({
//            url: 'add_address',
//        });
//    }

</script>
{/block}
{block name="caidan"}{/block}